-
-
Notifications
You must be signed in to change notification settings - Fork 18.5k
Refactor test_parquet.py to use check_round_trip at module level #19332
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Refactor test_parquet.py to use check_round_trip at module level #19332
Conversation
pandas/tests/io/test_parquet.py
Outdated
|
||
def test_options_py(df_compat, pa): | ||
# use the set option | ||
if engine: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is there a case where engine is not required?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, mostly when testing for "defaults" handling (i.e. default engine, or engine being configured via option_context
. Please see here https://github.com/pandas-dev/pandas/pull/19332/files#diff-539eb41a29c68cc27818db4b480c2fd6R163
pandas/tests/io/test_parquet.py
Outdated
def test_invalid_engine(df_compat): | ||
def check_round_trip(df, engine=None, path=None, | ||
write_kwargs=None, read_kwargs=None, | ||
expected=None, check_names=True): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can you add a proper doc-string here
pandas/tests/io/test_parquet.py
Outdated
df.to_parquet(path) | ||
if path is None: | ||
with tm.ensure_clean() as path: | ||
df.to_parquet(path, **write_kwargs) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can you make both of these into a loop with a kwarg in the signature repeat=2
for _ in range(repeat):
.....
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks...
Python is not native for me, I was looking for a nicer way to do that 👍
pandas/tests/io/test_parquet.py
Outdated
then compares the 2 resulting DataFrames to verify full | ||
cycle is successful. | ||
|
||
:param df: Dataframe to be serialized to disk |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
pls use the numpy-doc format (just at any other doc-string)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
include Parameters, Raises sections
pandas/tests/io/test_parquet.py
Outdated
then compares the 2 resulting DataFrames to verify full | ||
cycle is successful. | ||
|
||
:param df: Dataframe to be serialized to disk |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
include Parameters, Raises sections
Codecov Report
@@ Coverage Diff @@
## master #19332 +/- ##
==========================================
- Coverage 91.57% 91.54% -0.03%
==========================================
Files 150 150
Lines 48700 48700
==========================================
- Hits 44595 44583 -12
- Misses 4105 4117 +12
Continue to review full report at Codecov.
|
pandas/tests/io/test_parquet.py
Outdated
|
||
write_kwargs = write_kwargs or {'compression': None} | ||
read_kwargs = read_kwargs or {} | ||
expected = expected or df |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if expected is None:
expected = df
pandas/tests/io/test_parquet.py
Outdated
write_kwargs: dict of str:str, optional | ||
read_kwargs: dict of str:str, optional | ||
expected: DataFrame, optional | ||
Expected deserialization result |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
say otherwise will be equal to the input
thanks @maximveksler |
Refactoring and unification of testing approach in
test_parquet.py
module.Iteration upon work that was done for #19135 (comment)
git diff upstream/master -u -- "*.py" | flake8 --diff